Focus detection apparatus, control method and storage medium

ABSTRACT

A focus detection apparatus comprises: a reception unit configured to receive designation of a region within an image; a first setting unit configured to set one focus detection mode out of at least a first mode for performing focus detection with priority to a region of a subject and a second mode for performing focus detection with priority to the designated region; a second setting unit configured to set a focus detection region; a selection unit configured to select a region to focus on based on a focus detection result of the focus detection region; and a control unit, wherein the second setting unit, in the first mode, sets the focus detection region based on a result of a detection of a subject, and is the second mode, sets the focus detection region based on the designated region.

BACKGROUND OF THE INVENTION Field of the Invention

The present invention relates to a focus detection apparatus, a controlmethod and a storage medium.

Description of the Related Art

In recent years, regarding image capturing apparatuses such assingle-lens reflex cameras, the importance of a shooting method forperforming shooting while viewing a LV (live view) screen has beenincreasing. Also, regarding AR (autofocus) control that operates whenperforming shooting while viewing the LV screen, quality in the focusingoperation is demanded in addition to responsiveness for quick focusing.

As techniques for realizing AR control of an image capturing apparatus,a phase difference detection method and a contrast detection method areknown. In addition, recently, as an AR method that makes it possible toperform focusing at high speed and with high quality even at the time ofLV shooting, an on-imaging plane phase difference detection method forperforming the phase difference detection method on an image sensorplane is known. In this on-imaging plane phase difference detectionmethod, pupil division is performed on the imaging pixels of the imagesensor using a microlens, and a light beam is received by a plurality offocus detection pixels, and thereby focus detection can be performedwhile performing image capturing.

Incidentally, when performing such focus detection, a focus detectingoperation needs to be performed after determining which region to focuson. As a technique for determining the region to focus on, a techniquefor performing a focus detecting operation on a region detected by aface detection technique has been proposed (Japanese Patent Laid-OpenNo. 2003-107335). Moreover, a technique for performing a focus detectingoperation on any region of a shot image designated by the user has beenproposed (Japanese Patent Laid-Open No. 2009-37152).

However, with the technique proposed in Japanese Patent Laid-Open No.2003-107335, there are cases where, even with a face detectiontechnique, a face other than the face of the subject that thephotographer wants to shoot (in other words, a face outside of thedesired region) is detected, and focus detection cannot be performed asdesired. On the other hand, there are also cases where the user isprompted to designate a focus detection region as proposed in JapanesePatent Laid Open No. 2009-37152, in order to prevent a region outside ofthe desired region being focused on. However, if it is desired topreferentially perform focus detection on a person, or if the subjectthat it is desired to focus on moves in and out of the designatedregion, there are cases where focus detection cannot be performed asdesired.

SUMMARY OF THE INVENTION

The present invention has been made in consideration of theaforementioned problems, and realizes a technique that enables a focusdetecting operation in which erroneous focus detection on a peripheralsubject other than a main subject or with respect to a moving subject isreduced.

In order to solve the aforementioned problems, one aspect of the presentinvention provides a focus detection apparatus which performs focusdetection using image information obtained by performing imagecapturing, comprising: a reception unit configured to receivedesignation of a region within an image; a first setting unit configuredto set one focus detection mode out of a plurality of focus detectionmodes, wherein the focus detection modes include at least a first modefor performing focus detection with priority to a region of a subjectwithin the image and a second mode for performing focus detection withpriority to the designated region within the image received by thereception unit; a second setting unit configured to set a focusdetection region for performing the focus detection; a selection unitconfigured to select a region to focus on out of the focus detectionregion based on a focus detection result of the focus detection region;and a control unit configured to perform focus adjustment so as toobtain image information in which the region to focus on is in focus,wherein the second setting unit, in the first mode, in a case where asubject is detected, sets the focus detection region based on the regionof the subject, and in a case where a subject is not detected, sets thefocus detection region to a predetermined region, and in the secondmode, sets the focus detection region based on the designated region.

Another aspect of the present invention provides a focus detectionapparatus comprising: a detection unit configured to detect a subjectarea from an image signal output from an image sensor that captures asubject image using an imaging optical system and outputs the imagesignal; a reception unit configured to receive designation of a regionof the image signal output from the image sensor; a setting unitconfigured to set a focus detection area based on the designation of theregion; a focus detection unit configured to detect a focus state of thefocus detection area set by the setting unit; and a selection unitconfigured to select a focus area in which focus adjustment of theimaging optical system is to be performed, wherein the selection unit,in a case where a subject area is detected by the detection unit,selects a focus detection area that the subject area overlaps by apredetermined size or more as the focus area, and in a case where asubject area is not detected by the detection unit, preferentiallyselects a focus detection area whose focus state detected by the focusdetection unit indicates a close range side, out of the focus detectionarea set by the setting unit, as the focus area.

Still another aspect of the present invention provides a control methodof a focus detection apparatus which performs focus detection usingimage information obtained by performing image capturing, the methodcomprising: receiving designation of a region within an image; setting,as first setting, one focus detection mode out of a plurality of focusdetection modes, wherein the focus detection modes include at least afirst mode for performing focus detection with priority to a region of asubject within the image and a second mode for performing focusdetection with priority to the designated region within the image;setting, as second setting, a focus detection region for performing thefocus detection; selecting a region to focus on out of the focusdetection region based on a focus detection result of the focusdetection region; and controlling focus adjustment so as to obtain imageinformation in which the region to focus on is in focus; wherein in thesecond setting, in the first mode, in a case where a subject isdetected, the focus detection region is set based on the region of thesubject, and in a case where a subject is not detected, the focusdetection region is set to a predetermined region, and in the secondmode, the focus detection region is set based on the designated region.

Yet another aspect of the present invention provides a control method ofa focus detection apparatus, the method comprising: detecting a subjectarea from an image signal output from an image sensor that captures asubject image using an imaging optical system and outputs the imagesignal; receiving designation of a region of the image signal outputfrom the image sensor; setting a focus detection area based on thedesignation of the region; performing focus detection to obtain a focusdetection result of the focus detection area set in the setting; andselecting a focus area in which focus adjustment of the imaging opticalsystem is to be performed, wherein in the selecting, in a case where asubject area is detected in the detecting, a focus detection area thatthe subject area overlaps by a predetermined size or more is selected asthe focus area, and in a case where a subject area is not detected inthe detecting, a focus detection area whose focus detection resultdetected in the focus detection indicates a close range side ispreferentially selected, out of the focus detection area set in thesetting, as the focus area.

Still yet another aspect of the present invention provides anon-transitory computer-readable storage medium storing a program forcausing a computer to execute a control method of a focus detectionapparatus which performs focus detection using image informationobtained by performing image capturing, the method comprising: receivingdesignation of a region within an image; setting one focus detectionmode out of a plurality of focus detection modes, wherein the focusdetection modes include at least a first mode for performing focusdetection with priority to a region of a subject within an image and asecond mode for performing focus detection with priority to thedesignated region within the image; setting a focus detection region forperforming the focus detection; selecting a region to focus on out ofthe focus detection region based on a focus detection result of thefocus detection region; and performing focus adjustment so as to obtainimage information in which the region to focus on is in focus, whereinin the first mode, in a case where a subject is detected, the focusdetection region is set based on the region of the subject, and in acase where a subject is not detected, the focus detection region is setto a predetermined region, and in the second mode, the focus detectionregion is set based on the designated region.

Yet still another aspect of the present invention provides anon-transitory computer-readable storage medium storing a program forcausing a computer to execute a control method of a focus detectionapparatus which performs focus detection using image informationobtained by performing image capturing, the method comprising: detectinga subject area from an image signal output from an image sensor thatcaptures a subject image using an imaging optical system and outputs theimage signal; receiving designation of a region of the image signaloutput from the image sensor; setting a focus detection area based onthe designation of the region; detecting a focus detection result of theset focus detection area; and selecting a focus area in which focusadjustment of the imaging optical system is to be performed, wherein inthe selecting of the focus area, in a case where a subject area isdetected, a focus detection area that the subject area overlaps by apredetermined size or more is selected as the focus area, and in a casewhere a subject area is not detected, a focus detection area whose focusdetection result indicates a close range side is preferentiallyselected, out of the focus detection area set in the setting, as thefocus area.

According to the present invention, a focus detecting operation thatreduces erroneous focus detection on a peripheral subject other than amain subject or with respect to a moving subject is possible.

Further features of the present invention will become apparent from thefollowing description of exemplary embodiments (with reference to theattached drawings).

BRIEF DESCRIPTION OF THE DRAWINGS

The accompanying drawings, which are incorporated in and constitute apart of the specification, illustrate embodiments of the invention, andtogether with the description, serve to explain the principles of theinvention.

FIG. 1 is a block diagram showing an example of the functionconfiguration of a lens-interchangeable camera as an example of a focusdetection apparatus according to an embodiment of the present invention.

FIG. 2 is a flowchart showing an entire series of operations regardingfocus detection processing.

FIG. 3 is a flowchart showing a series of operations regardingcontinuous AF control and servo AF control.

FIG. 4 is a flowchart showing a series of operations in the case where acontrast AF method is adopted in focus detection control processing.

FIG. 5 is a flowchart showing a series of operations in the case wherean on-imaging plane phase difference AF method is adopted in focusdetection control processing.

FIG. 6 is a flowchart showing a series of operations of AF frame settingprocessing.

FIGS. 7A to 7E are diagrams schematically showing an example of AF framesetting.

FIG. 8 is a flowchart showing a series of operations when “facepriority” and “zone” are set in the case where a contrast AF method isadopted in focus detection control processing.

FIG. 9 is a flowchart showing a series of operations of representativeframe selection processing.

FIG. 10 is a flowchart showing a series of operations when “facepriority” and “zone” are set in the case where an on-imaging plane phasedifference AF method is adopted in focus detection control processing.

FIG. 11 is a flowchart showing a series of operations of representativeframe selection processing.

FIG. 12 is a diagram showing an example of an index assigned to each AFframe.

FIGS. 13A and 13B are diagrams schematically showing focus frame displaywhen “face priority” and “zone” are set.

DESCRIPTION OF THE EMBODIMENTS

An exemplary embodiment of the present invention will be described belowin detail with reference to the drawings. Note that a case will bedescribed below in which an interchangeable-lens digital single-lensreflex camera that has an AF function is used as an example of a focusdetection apparatus. However, this embodiment is not limited to aninterchangeable-lens camera, and can be applied to any devices that havean AF function. Such devices may include personal computers, mobilephones including smart phones, gaming devices, tablet terminals, watchor eye glass-type information terminals, medical devices, and devicesfor a monitoring system and an on-vehicle system, for example.

Configuration of Digital Camera

FIG. 1 is a block diagram showing an example of the functionconfiguration of a digital camera according to this embodiment. Notethat one or more functional blocks shown in FIG. 1 may be realized byhardware such as an ASIC or a programmable logic array (PLA), or may berealized by a programmable processor such as a CPU or an MPU executingsoftware. Also, the functional blocks may be realized by a combinationof software and hardware. Therefore, in the following description, evenif different functional blocks are described as performing an operation,these functional blocks can be realized by the same hardware performingthe operation.

As shown in FIG. 1, the digital camera of this embodiment has a lensunit 100 and a camera body 120. The lens unit 100 is mechanicallyconnected to the camera body 120 via a mount N indicated by a dottedline in the center the figure.

The lens unit 100 has a first lens group 101, a aperture/shutter 102, asecond lens group 103, a focus lens group (hereinafter, simply referredto as a “focus lens”) 104, and a control unit, which will be describedlater. As described above, the lens unit 100 includes the focus lens104, and has an imaging optical system for forming a subject image onthe imaging plane of an image sensor 122 of the camera body 120.

The first lens group 101 is arranged at the front end of the lens unit100, and is held so as to be able to advance and retreat in an opticalaxis direction OA. The aperture; shutter 102 performs light amountadjustment at the time of shooting by adjusting the opening diameterthereof, and functions as a shutter for exposure time adjustment at thetime of shooting a still image. The aperture/shutter 102 and the secondlens group 103 advance and retreat in the optical axis direction OA inan integrated manner, and realize a zoom function in conjunction withthe advancing/retreating operation of the first lens group 101. Thefocus lens 104 performs focus adjustment by advancing and retreating inthe optical axis direction.

The control unit of the lens unit 100 has a zoom actuator 111, aaperture/shutter actuator 112, a focus actuator 113, a zoom drivingcircuit 114, a aperture/shutter driving circuit 115, a focus drivingcircuit 116, lens control unit 117 and a lens memory 118.

The zoom actuator 111 drives the first lens group 101 and the secondlens group 103 to advance and retreat is the optical axis direction OAso as to perform a zoom operation. The aperture/shutter actuator 112controls the opening diameter of the aperture/shutter 102 so as toadjust a shooting light amount, and controls an exposure duration at thetime of shooting a still image. The focus actuator 113 drives the focuslens 104 to advance and retreat in the optical axis direction OA so asto perform focus adjustment. The focus actuator 113 has a function as aposition detection unit for detecting the current position of the focuslens 104. The zoom driving circuit 114 drives the zoom actuator 111according to a zoom operation performed by the photographer. Theaperture/shutter driving circuit 115 performs drive control of theaperture/shutter actuator 112 so as to control the opening of theaperture/shutter 102. The focus driving circuit 116 performs drivecontrol of the focus actuator 113 based on a focus detection result soas to drive the focus lens 104 to advance and retreat in the opticalaxis direction OA so as to perform focus adjustment.

The lens control unit 117 performs calculation and control related tothe imaging optical system for forming a subject image on the imagesensor 122, and controls the zoom driving circuit 114, theaperture/shutter driving circuit 115, the focus driving circuit 116 andthe lens memory 118. Also, the lens control unit 117 detects the currentlens position, and notifies lens position information in response to arequest from a camera control unit 125. The lens memory 118 storesoptical information required for automatic focus adjustment, and outputsthe optical information to the lens control unit 117.

The camera body 120 has an optical low-pass filter 121, the image sensor122, and a control unit, which will be described later. The opticallow-pass filter 121 reduces false color and moire of an image. The imagesensor 122 is constituted by a C-MOS sensor and peripheral circuitsthereof, for example, and one photoelectric conversion element isarranged on light receiving pixels composed of m pixels in thehorizontal direction and n pixels in the vertical direction. The imagesensor 122 is configured such that independent output from each of allthe pixels is possible. Moreover, a portion or all of the pixels arefocus detection pixels, and due to a configuration in which onemicrolens is arranged for a pair of focus detection pixels, phasedifference AF focus detection (on-imaging plane phase difference AF) ispossible on the imaging plane.

The control unit of the camera body 120 has an image sensor drivingcircuit 123, an image processing circuit 124, the camera control unit125, a display unit 126, an operation switch (SW) 127, a memory 128, anon-imaging plane phase difference focus detection unit 129, a TVAF focusdetection unit 130 and a face detection unit 131.

The image sensor driving circuit 123 controls operations of the imagesensor 122, and performs A/D conversion on analog image signals thathave been output from the image sensor 122, and transmits the convertedsignals as image information to the camera control unit 125. The imageprocessing circuit 124 performs γ conversion, color interpolation andJPEG compression on image information obtained from the image sensor122.

The camera control unit (processor) 125 performs calculation and controlin order to perform overall control of the camera body 120, and controlsconstituent elements such as the image sensor driving circuit 123 andthe image processing circuit 124. Also, the camera control unit 125 isconnected to the lens control unit 117 via a signal line of the mount M,and transmits, to the lens control unit 117, control signals forcontrolling obtaining of the lens position and lens driving by apredetermined drive amount, and receives optical information specific tothe lens unit 100. Furthermore, the camera control unit 125 includes aROM 125 a that stores a program for controlling a camera operation, aRAM 125 b that temporarily stores variables for operating a program, andan EEPROM 125 c that stores various parameters.

Furthermore, the camera control unit 125 executes focus detectionprocessing using the program stored in the RCM 125 a. The focusdetection processing will be described in detail later. In on-imagingplane phase difference AF on which focus detection processing is based,the influence of vignetting is large and reliability deteriorates whenthe image height at the focus detection position is high, and thus thecamera control unit 125 performs correction for such situations.

The display unit 126 is constituted by an LCD, an OLED or the like, anddisplays information regarding the shooting mode of the camera, apreview image before shooting and an image for checking after shooting,a focus state display image at the time of focus detection, a userinterface for settings or operations, and the like. The operation SW 127is constituted by a power switch, a release (shooting trigger) switch, aon operation switch, a shooting mode selection switch and the like. Thememory 128 of this embodiment is a removable flash memory, for example,and records shot images.

The on-imaging plane phase difference focus detection unit 129 performsfocus detection processing employing an on-imaging plane phasedifference AF method, using image signals of the focus detection pixelsembedded in the image sensor 122. More specifically, the on-imagingplane phase difference focus detection unit 129 performs on-imagingplane phase difference AF based on the shift amount of a pair of imagesformed by focus detection pixels from a light beam that has passedthrough a pair of pupil regions of the imaging optical system.

The TVAF focus detection unit 130 performs contrast focus detectionprocessing using the contrast components of image information obtainedin the image processing circuit 124. In the contrast focus detectionprocessing, the position of the focus lens at which a contrastevaluation value (TVAF evaluation value) peaks is detected regardingimage information that has been shot while performing shooting aftermoving the focus lens 104.

The face detection unit 131 extracts a feature amount from the imageinformation obtained by the image processing circuit 124, detects a faceof a person, and specifies the region of the face of the person in theimage. Note that a known face recognition technique can be used fordetecting a face of a person using image information.

Note that in this embodiment, description is given assuming thatprocessing of both an on-imaging plane phase difference AF method and acontrast AF method can be executed, but a configuration may be adoptedin which only either an on-imaging plane phase difference AF or acontrast AF method is provided.

Series of Operations Regarding Focus Detection Processing

Next, a series of operations regarding focus detection processing willbe described with reference to FIG. 2. Note that this processing isstarted when the power switch included in the operation SW 127 is turnedon, for example. In addition, this processing is realized by the cameracontrol unit 125 loading a program stored in the RPM 125 a to a workarea of the RAM 125 b and executing the program, and controllingconstituent elements such as the on-imaging plane phase difference focusdetection unit 129.

In step S200, the camera control unit 125 determines whether or not thesetting of continuous AF control is enabled. If it is determined thatthe setting of continuous AF control is enabled, the procedure advancesto step S201, and in step S201, continuous AF control for keeping thesubject in focus after the camera is started is executed. Descriptionthereof will be given in detail with reference to FIG. 3.

In step S202, the camera control unit 125 determines whether or not anoperation of the release (an AF start trigger) switch in the operationSW 127 has been detected, and if an AF start trigger has been detected,advances the procedure to step S203. On the other hand, if an AF starttrigger has not been detected, the procedure returns to step S200.

In step S203, the camera control unit 125 performs AF frame setting,which will be described later with reference to FIG. 6. An AF framedefines a region in which focus detection processing is performed in aregion that has been set as the AF frame (a focus detection region). Inthis embodiment, as the AF frame setting, three different AF frames,namely, “face priority”, “zone”, and “single point” can be set. Thesesettings can be made as appropriate by the user from the operation SW127 or a user interface of the display unit 126. Detailed descriptionwill be given with reference to FIG. 6. In step S204, the camera controlunit 125 executes focus detection control employing a contrast AF methodor focus detection control employing an on-imaging plane phasedifference AF method, which will be described later. Regarding these AFmethods, a configuration may be adopted in which the contrast AF methodor the on-imaging plane phase difference AR method switches dynamicallybased on the reliability of on-imaging plane phase difference AF, whichwill be described later. A configuration may also be adopted in whichfocus detection control is executed exclusively according to the form ofthe product. A technique for executing the focus detection control ofeach type will be described below assuming a configuration in whichthese AR methods are executed exclusively.

In step S205, the camera control unit 125 determines whether or not thesetting of servo AR control is enabled, and if the setting is enabled,advances the procedure to step S206. On the other hand, if the settingof servo AF control is not enabled, servo AR control is not executed,and the procedure advances to step S207. In step S206, the cameracontrol unit 125 executes servo AF control for keeping the subject infocus until a shooting instruction is given, and advances the procedureto step S207. The series of operations regarding servo AF controlprocessing is similar to continuous AF control processing, and thusdetailed description will be given with reference to FIG. 3. In stepS207, the camera control unit 125 determines whether or not a shootingtrigger has been detected, and if a shooting trigger has been detected,ends a series of operations regarding this processing. On the otherhand, if a shooting trigger has not been detected, the procedure returnsto step S205. Note that focus detection control of steps S202 to S204can be applied to AF during continuous shooting and the like.

Series of Operations Regarding Continuous AF Control Processing

Next, the continuous AF control processing regarding step S201 in FIG. 2will be described with reference to FIG. 3. Note that as describedabove, the continuous AF control processing can also be applied to theservo AF control processing of step S206 in FIG. 2.

In step S300, the camera control unit 125 performs the above describedAF frame setting in step S205. Note that the AF frame setting will bedescribed later with reference to FIG. 6 and the like. In step S301,focus detection control, which will be described later with reference toFIGS. 4 and 5, is performed. In step S302, the camera control unit 125stores a phase difference evaluation value (hereinafter, also referredto as a defocus amount) or a contrast evaluation value in the RAM 125 baccording to the AF method adopted for focus detection control. In stepS303, the camera control unit 125 determines whether or not to performrestart. Restart determination is performed such that, if a storedevaluation value and a newly detected evaluation value are different byan evaluation value threshold or more, at is determined that restartshould be performed. Alternatively, if the movement amount of thesubject is greater than a movement amount threshold according to themovement amount of the subject, it may be determined that restart shouldbe performed. If it is determined that restart should be performed, thecamera control unit 125 returns the procedure to step S300, and executesthe focus detection AF operation again. On the other hand, if it isdetermined to not perform restart, this series of operations is ended.In this manner, the basic operations of continuous AF control and servoAF control are similar, but in this embodiment, the control cycle ofservo AF is set at a higher speed than continuous AF control. This makesit possible to suppress power consumption before AF start is triggered,and to perform focus tracking at a higher speed after an AF instruction.In addition, a configuration may be adopted in which it is determinedaccording to the movement state of the subject whether or not to executecontinuous AF control and servo AF control, or selection may beperformed according to a user operation.

Series of Operations Regarding Contrast AF Method

Furthermore, a series of operations in the case where a contrast AFmethod is adopted in focus detection control in step S204 will bedescribed with reference to FIG. 4. The case of a single point AF framesetting will be described in order to simplify the description. Notethat this series of processing is executed by the camera control unit125 controlling the TVAF focus detection unit 130.

In step S400, the camera control unit 125, via the lens control unit117, exposes the image sensor 122 at a plurality of focus lens positionsin order to calculate contrast evaluation values. In step S401, the TVAFfocus detection unit 130 obtains contrast evaluation values based onimage information obtained by the exposure. In step S402, the TVAF focusdetection unit 130 determines whether or not a peak has been detected inthe contrast evaluation values. The peak of the contrast evaluationvalue is determined according to whether or not a local maximum valuethat is greater than or equal to a predetermined value has been detectedamong the contrast evaluation values obtained at the focus lenspositions. If at is determined that a peak has been detected, the TVAFfocus detection unit 130 advances the procedure to step S404. On theother hand, if it is not determined a peak has been detected, theprocedure advances to step S403.

In step S404, the camera control unit 125 uses the lens control unit 117to move the focus lens 104 to the peak position detected in step S402.In step S407, the camera control unit 125 stands by until the focus lens104 is driven to the peak position (in other words, repeats theprocessing of step S407), and if it is determined that the focus lens104 has been driven to the peak position, advances the procedure to stepS409. After that, in step S409, the focus state transitions to anin-focus state. The camera control unit 125 then ends this series ofprocessing.

On the other hand, in step S403, the TVAF focus detection unit 130determines whether or not to end scanning. In the scanning enddetermination, whether or not the entire region from a near end to a farend has been scanned is determined. If it is determined that the entireregion has been scanned, it is determined that scanning is complete, andthe procedure advances to step S405. On the other hand, if it isdetermined the entire region has not been scanned, it is determined thatscanning is not complete, and the procedure advances to step S406. Instep S406, the TVAF focus detection unit 130 moves focusing by apredetermined amount, continues the scanning, and returns the procedureto step S400.

In step S405, the camera control unit 125 moves the focus lens 104 to anappropriate fixed point position since a peak could not be detected. Thefixed point position may be the scanning start position or a hyperfocalposition. After that, in step S408, the camera control unit 125determines, based on the information from the lens control unit 117,whether or not movement of the focus lens 104 to the fixed pointposition is complete. If it is determined that movement to the fixedpoint position is complete, the procedure advances to step S410, and itis determined that movement to the fixed point position is not complete,the procedure returns to step S408. Note that the lens does not need tobe driven from the scanning end position in order to shorten the focusdetection time.

After that, in step S410, the camera control unit 125 performstransition to an out-of-focus state, and ends this series of processing.Note that in steps S409 and S410, a configuration may be adopted inwhich the user uses the operation SW 127 or the like to determinewhether the state is an an-focus state or an out-of-focus state, and thecamera control unit 125 performs transition to each state. In this case,the camera control unit 125 outputs, to the display unit 126 and thelike, display indicating the focus state of the current imageinformation. For example, it is sufficient that if the focus state is anin-focus state, an AF frame that has been set is displayed in green, andif the focus state is an out-of-focus state, the AF frame is displayedin red, or the like. Moreover, in step S205, if it is determined thatservo AF control is enabled, the focus display is updated every timefocus detection control of step S301 shown in FIG. 3 is repeated.

Series of Operations Regarding On-Imaging Plane Phase Difference AFMethod

Next, a series of operations in the case where an on-imaging plane phasedifference AF method is adopted in focus detection control in step S204will be described with reference to FIG. 5. In order to simplify thedescription, the case of setting single point AF frame will bedescribed. Note that this series of processing is executed by the cameracontrol unit 125 controlling the on-imaging pjane phase difference focusdetection unit 129.

In step S500, the camera control unit 125 exposes the image sensor 122in order to obtain image information for calculating a defocus amount.In step S501, the on-imaging plane phase difference focus detection unit129 obtains a defocus amount based on the image information according toan instruction of the camera control unit 125. In step S502, theon-imaging plane phase difference focus detection unit 129 determineswhether or not the reliability of the phase difference is high, anddetermines whether or not the defocus amount can be used. For example,this reliability of the phase difference can be obtained according to animage height or an F-number, and whether or not the obtained reliabilitycan be used can be determined according to whether or not thereliability is greater than or equal to a predetermined reliabilitythreshold, but another method may be used. If the reliability of thephase difference is greater than or equal to the predeterminedreliability threshold, the on-imaging plane phase difference focusdetection unit 129 advances the procedure to step S504, and if thereliability of the phase difference is smaller than the predeterminedreliability threshold, determines that the reliability of the phasedifference is low, and advances the procedure to step S505.

In step S504, the on-imaging plane phase difference focus detection unit129 determines whether or not the defocus amount for achieving anin-focus position is within the depth of focus, and if it is determinedthat the defocus amount is within the depth of focus, performstransition to an in-focus state in step S510, and ends the processing.On the other hand, if it is determined that the defocus amount isoutside of the depth of focus, the on-imaging plane phase differencefocus detection unit 129 advances the procedure to step S509. In stepS509, the camera control unit 125 moves the focus lens 104 by a defocusdrive amount corresponding to the defocus amount obtained in step S501,and then advances the procedure to step S500.

In step S505, the on-imaging plane phase difference focus detection unit129 determines whether or not the entire region from the far end to thenear end has been scanned in order to move the position of the focuslens 104 so as to obtain a defocus amount of higher reliability. If itis determined that the entire region has not been scanned, theon-imaging plane phase difference focus detection unit 129 advances theprocedure to step S507, and on the other hand, if the entire region hasbeen scanned, advances the procedure to step S506. In step S507, forexample, the camera control unit 125 moves the focus lens 104 by apredetermined amount, returns the procedure to step S500, and continuesscanning.

In step S506, the camera control unit 125 moves the position of thefocus lens 104 to an appropriate fixed point position since an in-focusposition could not be detected. This fixed point position may be thescanning start position or a hyperfocal position. After that, in stepS508, the camera control unit 125 determines, based on information fromthe lens control unit 117, whether or not movement of the focus lens 104to the fixed point position is complete. If it is determined thatmovement to the fixed point position is complete, the procedure advancesto step S511, and if it is determined that movement to the fixed pointposition is not complete, the procedure returns to step S508. Note thatthe lens does not need to be driven from the scanning end position inorder to reduce the focus detection time.

After that, the step S511, the camera control unit 125 performs statetransition to an out-of-focus state, and ends the processing. Note thatin steps S510 and S511, as described above, a configuration may beadopted in which the user uses the operation SW 127 or the like todetermine whether the focus state is an in-focus state or anout-of-focus state, and the camera control unit 125 performs transitionto each state, and display of the display unit 126 may be controlledsimilarly to the case of steps S409 and S410.

Series of Operations Regarding AF Frame Setting Processing

Furthermore, a series of operations regarding the AF frame settingprocessing of step S203 in FIG. 2 and step S300 in FIG. 3 will bedescribed with reference to FIG. 6. In this processing, a region forperforming focus detection is determined according to informationregarding AF frame setting that has been made by the user, and theregion is set as an AF frame.

In step S600, the camera control unit 125 reads out informationregarding the AF frame setting that has been made by the user, from theEEPROM 125 c, for example, and determines whether or not setting of“face priority” has been made. If “face priority” is set, the procedureadvances to step S602, and if “face priority” is not set, the procedureadvances to step S601.

In step S601, the camera control unit 125 determines whether or not“zone” (namely, a region within the image) is set as AF frame setting.For example, data is read out from the EEPROM 125 c, and it isdetermined that a zone within the image for performing face detectionprocessing is set, the procedure advances to step S603. On the otherhand, if it is determined that such a zone is not set, it is determinedthat a single point AF frame is set, and the procedure advances to stepS608.

In step S602, the face detection unit 131 determines whether or not aface has been detected, according to an instruction of the cameracontrol unit 125. As described above, a known face detection techniquecan be used for detecting a face, and, for example, if the position andsize of a valid face region was obtained as a result of the facedetection processing, it is determined that a face has been detected,and the procedure advances to step S604. On the other hand, if aneffective position and size of a face region was not obtained, it isdetermined that a face has not been detected, and the procedure advancesto step S605.

In step S604, the camera control unit 125 sets, at the central positionof the detected face, an AF frame that is constituted by i horizontalregions and j vertical regions of a predetermined size and includes theface region. An AF frame constituted by a plurality of regions centeredon the face is set in order to avoid a case where, if the subject ismoving in the screen direction (if the size of the subject changes), thesubject moves out of the detection range depending on the speed if theAF frame is composed of only one region, and erroneous distancemeasurement is performed. In addition, information obtained from aperipheral AF frame can also be used. However, if it is desired toreduce the processing time, an AF frame composed of a 1×1 region mayalso be set. For example, FIGS. 7A and 7B show an AF frame that is setin this embodiment. The example in FIG. 7A is an example in which theabove AF frame is set using a plurality of regions (3×3), and theexample in FIG. 7B is an example in which an AF frame composed of 1×1region is set.

On the other hand, if it is determined in step S602 that a face has notbeen detected, the camera control unit 125 sets k horizontal AF framesand l vertical AF frames in a region of X % of the entire screen in stepS605. This X is set for preventing focus detection from being performedon a subject in the periphery other than the main subject, byrestricting the region to a region in which it is highly possible thatthe user will perform focusing (in other words, restricting the range offocus detection within the range of X % of the entire screen). FIG. 7Cschematically shows AF frames that have been set in the above step S605.

In step S603, the camera control unit 125 determines whether or not thecenter coordinates of the zone have been set by the user. This settingis made using a configuration that makes it possible to change thecenter coordinates, for example, via a touch panel (not illustrated), orvia an arrow key included in the operation SW 127. If it is determinedthat the center coordinates of the above-described zone have been setvia the above-described touch panel or the operation SW 127, the cameracontrol unit 125 advances the procedure to step S606. On the other hand,if it is determined that the center coordinates of the above zone havenot been designated, the camera control unit 125 advances the procedureto step S607.

In step S606, the camera control unit 125 sets, at the designated centercoordinates, n horizontal AF frames and m vertical AF frames in a regionof Y % of the entire image. Note that this Y % is set to obtain a regionsmaller than the region of X % of the entire image that is set in stepS605. This configuration is adopted in order to realize, in a scene inwhich focus detection is performed outside of the desired region afterhaving performed focus detection in the region set in step S605, focusdetection in the region intended by the user by narrowing the region tobe subjected to focus detection. On the other hand, if the region to besubjected to focus detection is greater than in the case of a singlepoint AF frame setting to be described later, the coordinates of theregion of Y % of the entire image can be designated easily, and asdescribed above, information regarding a plurality AF frames is obtainedfor a subject that moves in the screen direction, and thus focusdetection tracking ability improves. FIG. 7D schematically shows anexample of AF frames that are set in step S606 in the case where anupper left portion of the image is designated. In step S607, the cameracontrol unit 125 sets (as a default setting) n horizontal AFframes and mvertical AF frames (in other words, a region of the same range as in thecase of step S606) in th region of Y % of the entire image with respectto the screen center.

A series of operations of step S608 onward is setting of an AF framecomposed of one region. This AF frame setting is set in the case whereit is desired to execute focus detection on a static subject in apinpoint region. FIG. 7E schematically shows the setting of this 1×1 AFframe. In step S608, the camera control unit 125 determines whether ornot AF frame coordinates have been designated by the user. If it isdetermined that the coordinates of the AF frame have been set via theabove-described touch panel or the operation SW 127, the camera controlunit 125 advances the procedure to step S609. On the other hand, if itis determined that the above AF frame has not been designated, thecamera control unit 125 advances the procedure to step S610. In stepS609, the camera control unit 125 sets one AF frame of a predeterminedsize at the designated coordinates. On the other hand, in step S610, thecamera control unit 125 sets one AF frame at the screen center (as adefault setting). The camera control unit 125 then ends this series ofoperations.

Series of Operations Regarding Contrast AF Method

Next, a series of operations in the case where a contrast AF method isadopted in focus detection control when “face priority” or “zone” is set(different from the case in which one AF frame is set as was describedwith reference to FIG. 4) will be described with reference to FIG. 8.

In step S801, the camera control unit 125 uses the lens control unit 117to expose the image sensor 122 at a plurality of focus lens positions inorder to calculate contrast evaluation values. In step S802, the TVAFfocus detection unit 130 obtains (calculates) contrast evaluation valuesfor the number of set frames based on image information obtained by theexposure. In step S803, the camera control unit 125 selects arepresentative frame for performing focus control. The representativeframe is an AF frame that is prioritized in focus detection control whena plurality of AF frames as illustrated FIGS. 7A, 7C and 7D are set, forexample. Detailed description will be given with reference to FIG. 9.

In step S804, the camera control unit 125 determines whether or not arepresentative frame has been selected in step S803. For example, instep S907 to be described later, if there is a representative framestored in the RAM 125 b, the camera control unit 125 determines that arepresentative frame has been selected, and advances the procedure tostep S806. On the other hand, if there is no representative frame, it isdetermined that a representative frame has not been selected, and theprocedure advances to step S805.

In step S806, the camera control unit 125 uses the lens control unit 117to move the focus lens to the peak position of the representative frameselected in step S803. In step S809, the camera control unit 125 standsby until the focus lens 104 is driven to the peak position (in otherwords, repeats the processing of step S809), and if it is determinedthat the focus lens 104 has been driven to the peak position, advancesthe procedure to step S811. After that, in step S811, the statetransitions to an in-focus state. The camera control unit 125 then endsthis series of processing.

On the other hand, in step S805, the TVAF focus detection unit 130determines whether or not to end scanning. In the scanning enddetermination, it is determined whether or not the entire region fromthe far end to the near end has been scanned. If it is determined thatthe entire region has been scanned, it is determined that scanning iscomplete, and the procedure advances to step S807. On the other hand, ifit is determined that the entire region has not been scanned, it isdetermined that scanning is not complete, and the procedure advances tostep S808. In step S808, the camera control unit 125 moves focusing by apredetermined amount to continue scanning, and returns the procedure tostep S801.

In step S807, the camera control unit 125 moves the focus lens 104 to anappropriate fixed point position since a peak could not be detected. Thefixed point position may be the scanning start position or a hyperfocalpositon. After that, in step S810, the camera control unit 125determines, based on information from the lens control unit 117, whetheror not movement of the focus lens 104 to the fixed point position iscomplete. If it is determined that movement to the fixed point positionis complete, the procedure advances to step S812, and if it isdetermined that movement to the fixed point position is not complete,the procedure returns to step S810. Note that the lens does not need tobe driven from the scanning end position in order to shorten the focusdetection time.

After that, in step S812, the camera control unit 125 performstransition to an out-of-focus state, and ends this series of processing.If the focus state transitions to an in-focus state/out-of-focus statein steps S811 and S812 according to a user operation using the operationSW 127 or the like, display indicating the current focus state is outputto the display unit 126 and the like. It is sufficient that, forexample, the AF frame that has been set is displayed in green in thecase of an in-focus state, and the AF frame is displayed in red in thecase of an out-of-focus state, and the like. In a mode for setting aplurality of AF frames, an AF frame within the depth of focus is alsobrought into focus and displayed with respect to the peak position ofthe representative frame. Here, in step S205, if it is determined thatservo AF control is enabled, focus display is updated every time focusdetection control of step S301 shown in FIG. 3 is repeated.

Series of Operations Regarding Processing for Selecting RepresentativeFrame

Next, a series of processing regarding processing for selecting arepresentative frame in step S803 in FIG. 8 will be described withreference to FIG. 9. In this processing example, the camera control unit125 repeats the processing of steps S901 to S909 for the number offrames that have been set in step S901, the TVAF focus detection unit130 determines whether or not a peak has been detected in any of the AFframes that have been set. A peak is determined according to whether ornot a local maximum value that is greater than or equal to apredetermined value has been detected among the contrast evaluationvalues obtained at the positions of the focus lens 104. If it isdetermined that a peak has been detected in any of the AF frames thathave been set, the TVAF focus detection unit 130 advances the procedureto step S902, and if it is not determined that a peak has been detected,advances the procedure to step S903.

In step S902, the camera control unit 125 determines whether or not thezone described above with reference to FIG. 6 has been set. If it isdetermined that the zone has been set, similarly to step S601, thecamera control unit 125 advances the procedure to step S903, and if itis determined that the zone has not been set, advances the procedure tostep S905. In step S903, the camera control unit 125 determines whetheror not a face has been detected in the zone by the face detection unit131. In this determination, hysteresis is applied such that thedetection result does not switch frequently in a short period, and, forexample, if a face is detected in a region over a certain period of timeor more, it is determined that the state is a detection state. Thiscertain period of time may be changed according to movement of thesubject or the like. If a face of a person has been detected in the zoneby the face detection unit 131, the camera control unit 125 advances theprocedure to step S904, and if a face of a person has not been detectedin the zone, advances the procedure to step S905.

In step S904, the camera control unit 125 determines whether or not theregion of the face overlaps the AF frame by a predetermined size ormore. As this predetermined size, a size that does not result inerroneous distance measurement at the in-focus position and the in-focusposition of the face is set. In step S905, the camera control unit 125determines whether or not the peak position of the current AF frame isfurthest on the close range side. If the peak of the current AF frame isfurther on the close range side than the peak of the AF frame stored ina previous set frame to be processed, this peak position is stored asthe closest range position for focus drive in the RAM 125 b in stepS906. Furthermore, the closest-range AF frame stored in step S907 isstored as a representative frame in the RAM 125 b, for example. Notethat in this embodiment, the closest-range frame is adopted also if aface is detected, but the peak position obtained from an AF frame in thevicinity of the position of the eye may be stored as a peak position forfocus driving depending on the scene and the size of the face region,and used as a representative frame.

In step S905, if it is determined that the peak position of the currentAF frame is not the closest-range peak position, the camera control unit125 advances the procedure to step S908. In step S908, the cameracontrol unit 125 then stores the peak position for determining whetheror not the focus frame that is set in step S811 is within the depth offocus. Furthermore, in step S909, the camera control unit 125 causes anindex for determining which frame position to display at the time offocus display in step S811 to be stored. The camera control unit 125uses this index at the time of focus display to determine which AF frameto display. For example, FIG. 12 shows a display example when indicesare assigned. In addition, FIG. 13A shows an example of focus display atthe time of face detection when “face priority” is set, and FIG. 13Bshows an example of focus display at the time of face detection when“zone” is set. In this embodiment, display appearance is differentiatedwhen “face priority” is set and when “zone” is set. For example, in thecase of “face priority”, a focus frame is displayed explicitly over theentire face, and in the case of “zone”, frames indicated by indexnumbers 5, 6, 8 and 9 in FIG. 12 are displayed as focus frames. Withsuch a configuration, the user can easily understand, when using adigital camera, which frame setting is selected, in other words, whetherfocus detection is currently being performed with priority to face, zoneor the like. When the camera control unit 125 finishes repeating theprocessing for the number of frames that have been set, this series ofoperations ends.

Series of Operations Regarding On-Imaging Plane Phase Difference AFMethod

Furthermore, a series of operations in the case where as on-imagingplane phase difference AF method is executed in focus detection controlwhen “face priority” or “zone” is set (this case is different from thecase in which one AF frame is set as was described with reference toFIG. 5) will be described with reference to FIG. 10.

In step S1000, the camera control unit 125 exposes the image sensor 122in order to obtain image information for calculating a defocus amount.In step S1001, the on-imaging plane phase difference focus detectionunit 129 obtains defocus amounts for the number of AF frames that havebeen set, based on the image information, according to an instruction ofthe camera control unit 125. In step S1002, the camera control unit 125selects a representative frame for performing focus control. Detaileddescription will be given with reference to FIG. 11.

In step S1003, the camera control unit 125 determines whether or not arepresentative frame has been selected. For example, if there is arepresentative frame that is stored in the RAM 125 b in step S1107 to bedescribed later, the camera control unit 125 determines that arepresentative frame has been selected, and advances the procedure tostep S1004. On the other hand, if there is no representative frame, itis determined that a representative frame has not been selected, and theprocedure advances to step S1005.

In step S1004, the on-imaging plane phase difference focus detectionunit 129 determines whether or not the defocus amount to the in-focusposition in the representative frame is within the range of depth offocus. If it is determined that the defocus amount is within the depthof focus, the procedure advances to step S1010, and if it is determinedthat the defocus amount is not within the depth of focus, the procedureadvances to step S1009. In step S1010, the camera control unit 125performs state transition to an in-focus state, and ends this series ofprocessing.

On the other hand, in step S1009, the camera control unit 125 moves thefocus lens 104 by a driving amount corresponding to the defocus amountobtained in step S1001 based on the defocus amount. After that, theprocedure returns to step S1000.

On the other hand, in step S1005, the on-imaging plane phase differencefocus detection unit 129 determines whether or not the entire regionfrom the near end to the far end has been scanned, in order to move theposition of the focus lens 104 so as to obtain a defocus amount ofhigher reliability. If it is determined that the entire region has notbeen scanned, the on-imaging plane phase difference focus detection unit129 advances the procedure to step S1007, and on the other hand, if theentire region has been scanned, advances the procedure to step S1006. Instep S1007, the camera control unit 125 moves the focus lens 104 by apredetermined amount, for example, returns the procedure to step S1000,and continues scanning.

In step S1006, the camera control unit 125 moves the position of thefocus lens 104 to an appropriate fixed point, position since an in-focusposition could not be detected. This fixed point position may be thescanning start position or a hyperfocal position. After that, in stepS1008, the camera control unit 125 determines, based on information fromthe lens control unit 117, whether or not movement of the focus lens 104to the fixed point position is complete. If it is determined thatmovement to the fixed point position is complete, the procedure advancesto step S1011, and if it is determined that movement to the fixed pointposition is not complete, the procedure returns to step S1008. Note thatthe lens does not need to be driven from the scanning end position inorder to shorten the focus detection time.

After that, in step S1011, the camera control unit 125 performs statetransition to an out-of-focus state, and ends the processing. In stepsS1010 and S1011, when the focus state transitions to an in-focusstate/out-of-focus state according to a user operation using theoperation SW 127 or the like, the camera control unit 125 outputs, tothe display unit 126 and the like, display indicating the current focusstate. For example, it is sufficient that an AF frame that has been setis displayed in green in the case of an in-focus state, an AF frame isdisplayed in red in the case of an out-of-focus state, and the like.Here, if it is determined in step S205 that servo AF control is enabled,as shown in FIG. 3, focus display is updated every time focus detectioncontrol in step S301 is repeated.

Series of Operations Regarding Processing for Selecting RepresentativeFrame

Furthermore, a series of operations regarding processing for selecting arepresentative frame in step S1002 shown in FIG. 10 will be describedwith reference to FIG. 11. In this processing example, the processing ofsteps S1101 to S1109 is repeated for the number of frames that have beenset by the camera control unit 125.

In step S1101, the on-imaging plane phase difference focus detectionunit 129 determines whether or not an AF frame of high reliability hasbeen detected among AF frames that have been set. If it is determinedthat an AF frame of high reliability has been detected, the on-imagingplane phase difference focus detection unit 129 advances the procedureto step S1102, and on the other hand, if it is determined that all theAF detection frames are not highly reliable, advances the procedure tostep S1103.

In step S1102, it is determined whether or not the zone described abovewith reference to FIG. 6 has been set. Similarly to step S601, if it isdetermined that the zone has been set, the camera control unit 125advances the procedure to step S1103, and if it is determined that thezone has not been set, advances the procedure to step S1105.

In step S1103, the camera control unit 125 determines whether or not aface has been detected in the zone by the face detection unit 131. Inthis determination, hysteresis is applied such that the detection resultdoes not switch frequently in a short period, and, for example, if aface is detected in a region over a certain period of time or more, itis determined that the state is a detection state. This certain periodof time may be changed according to the movement of the subject or thelike. In step S1104, the camera control unit 125 determines whether ornot the region of the face overlaps the AF frame by a predetermined sizeor more. As this predetermined size, a size that does not result inerroneous distance measurement at the in-focus position of thebackground and the in-focus position of the face is set.

In step S1105, the camera control unit 125 determines whether or not thedefocus position (in-focus position) of the current AF frame is furtheston the close range side. If the current defocus position is further onthe close range side than the defocus position on the close range sidestored in a previous set frame to be processed, this defocus position isstored as the closest range position for focus drive in the RAM 125 b instep S1106. Furthermore, in step S1107, the camera control unit 125causes the RAM 125 b to store the stored closest range AF frame as arepresentative frame, for example. Note that in this embodiment, theclosest range frame is also adopted in the case where a face has beendetected, but depending on a scene and a face region size, a defocusposition obtained from an AF frame in the vicinity of the position ofthe eye may be stored as a defocus position for focus drive, and used asa representative frame.

In step S1105, if it is determined that the peak position of the currentAF frame is not the closest range defocus position, the camera controlunit 125 advances the procedure to step S1108. After that, in stepS1108, the camera control unit 125 stores a defocus position fordetermining whether or not the representative frame is within the depthof focus at the time of focus display in step S1010. Furthermore, instep S1109, the camera control unit 125 causes an index for determiningwhich frame position to display at the time of focus display in stepS1010 to be stored. When the camera control unit 125 finishes repeatingthe processing for the number of frames that have been set, this seriesof operations ends.

As described above, in this embodiment, a configuration is adopted inwhich during AF frame (in other words, focus detection region) setting,if “face priority” is set, focus detection is not performed on theregion of a subject detected outside of the focus detection region, anda focus detection region is determined within a region of apredetermined size. Specifically, a face region has been detected, theface region is determined as the focus detection region, and if a faceregion has not been detected, the region of the predetermined size isdetermined as the focus detection region. With such a configuration,erroneous focus detection of a subject that appears on the periphery ofthe image other than the main subject can be reduced. In addition, if“zone” is set, at a position regarding zone designation, a region of arange that is smaller than the above region of the predetermined size inthe case of the face priority setting is set as the focus detectionregion. With such a configuration, it becomes possible to strengthenrestriction on the position/range over restriction that is based on facedesignation, and to reduce erroneous focus detection of a peripheral ormovthg subject. In other words, it becomes possible to perform a focusdetecting operation in which incorrect focus detection with respect to aperipheral subject other than a main subject or a moving subject isreduced.

Other Embodiments

Embodiment(s) of the present invention can also be realized by acomputer of a system or apparatus that reads out and executes computerexecutable instructions (e.g., one or more programs) recorded on astorage medium (which may also be referred to more fully as a‘non-transitory computer-readable storage medium’) to perform thefunctions of one or more of the above-described embodiment(s) and/orthat includes one or more circuits (e.g., application specificintegrated circuit (ASIC)) for performing the functions of one or moreof the above-described embodiment(s), and by a method performed by thecomputer of the system or apparatus by, for example, reading out andexecuting the computer executable instructions from the storage mediumto perform the functions of one or more of the above-describedembodiment(s) and/or controlling the one or more circuits to perform thefunctions of one or more of the above-described embodiment(s). Thecomputer may comprise one or more processors (e.g., central processingunit (CPU), micro processing unit (MPU)) and may include a network ofseparate computers or separate processors to read out and execute thecomputer executable instructions. The computer executable instructionsmay be provided to the computer, for example, from a network or thestorage medium. The storage medium may include, for example, one or moreof a hard disk, a random-access memory (RAM), a read only memory (ROM),a storage of distributed computing systems, an optical disk (such as acompact disc (CD), digital versatile disc (DVD), or Biu-ray Disc (BD)™),a flash memory device, a memory card, and the like.

While the present invention has been described with reference toexemplary embodiments, it is to be understood that the invention is notlimited to the disclosed exemplary embodiments. The scope of thefollowing claims is to be accorded the broadest interpretation so as toencompass all such modifications and equivalent structures andfunctions.

This application claims the benefit of Japanese Patent Application No.2016-122875, filed Jun. 21, 2016, which is hereby incorporated byreference herein in its entirety.

What is claimed is:
 1. A focus detection apparatus which performs focusdetection using image information obtained by performing imagecapturing, comprising: a memory storing a set of instructions; and atleast one processor that executes the set of instructions to functionas: a reception unit configured to receive designation of a regionwithin an image; a first setting unit configured to set one focusdetection mode out of a plurality of focus detection modes, wherein thefocus detection modes include at least a first mode for performing focusdetection with priority to a region of a subject within the image and asecond mode for performing focus detection with priority to thedesignated region within the image received by the reception unit; asecond setting unit configured to set a focus detection region forperforming the focus detection; a selection unit configured to select aregion to focus on out of the focus detection region based on a focusdetection result of the focus detection region; and a control unitconfigured to perform focus adjustment so as to obtain image informationin which the region to focus on is in focus, wherein the second settingunit, in the first mode, in a case where a subject is detected, sets thefocus detection region based on the region of the subject, and in a casewhere a subject is not detected, sets the focus detection region to apredetermined region, and in the second mode, sets the focus detectionregion based on the designated region, wherein the second setting unit,in the second mode, in a case where a region is designated in the imageby the reception unit, set, in a partial region of the image, the focusdetection region based on designated coordinates as a center, and in acase where a region within the image is not designated by the receptionunit, set, in a partial region of the image, the focus detection regionbased on a center of the image, wherein, in the second mode, a focusstate is displayed for each focus detection region regardless of whetheror not a subject is detected.
 2. The apparatus according to claim 1,wherein the focus detection modes include a third mode for performingfocus detection in one region within the image.
 3. The apparatusaccording to claim 1, wherein the second setting unit, in the secondmode, sets the focus detection region regardless of whether or not asubject is detected.
 4. The apparatus according to claim 1, wherein theselection unit selects one of a plurality of regions included in thefocus detection region as the region to focus on, based on a focusdetection result for each of the plurality of regions.
 5. The apparatusaccording to claim 1, wherein the at least one processor furtherfunctions as comprising: a display control unit configured to performcontrol for displaying a focus state in the focus detection region;wherein the display control unit performs control such that a displayappearance of a focus state differs in a case where the focus state isevaluated in the first mode and in a case where the focus state isevaluated in the second mode.
 6. The apparatus according to claim 4,wherein the at least one processor further functions as comprising: adisplay control unit configured to perform control for displaying afocus state in the focus detection region, wherein the display controlunit performs control so as to display a focused region as one frame inthe first mode, and to display the focused region as a plurality offrames in the second mode.
 7. The apparatus according to claim 1,wherein in a case where the region of the detected subject is greaterthan or equal to a predetermined size, and has existed in the focusdetection region for a predetermined time period, the selection unitincludes the region of the subject in the region to focus on.
 8. Theapparatus according to claim 1, wherein the selection unit obtains afocus state in the focus detection region, based on a contrast of imageinformation obtained by performing image capturing at a plurality offocus lens positions.
 9. The apparatus according to claim 1, wherein theselection unit obtains a focus state in the focus detection region basedon a shift amount of a pair of image signals formed from a light beamthat has passed through different pupil regions of an imaging opticalsystem, the shift amount being included in the image informationobtained by performing image capturing.
 10. The apparatus according toclaim 1, wherein the at least one processor further functions ascomprising: a detection unit configured to detect the region of thesubject within the image, wherein the detection unit detects a region ofa face of a person as the region of the subject.
 11. A control method ofa focus detection apparatus which performs focus detection using imageinformation obtained by performing image capturing, the methodcomprising: receiving designation of a region within an image; setting,as first setting, one focus detection mode out of a plurality of focusdetection modes, wherein the focus detection modes include at least afirst mode for performing focus detection with priority to a region of asubject within the image and a second mode for performing focusdetection with priority to the designated region within the image;setting, as second setting, a focus detection region for performing thefocus detection; selecting a region to focus on out of the focusdetection region based on a focus detection result of the focusdetection region; and controlling focus adjustment so as to obtain imageinformation in which the region to focus on is in focus; wherein in thesecond setting, in the first mode, in a case where a subject isdetected, the focus detection region is set based on the region of thesubject, and in a case where a subject is not detected, the focusdetection region is set to a predetermined region, and in the secondmode, the focus detection region is set based on the designated region,wherein in the second setting, in the second mode, in a case where aregion is designated in the image in the receiving a designation,setting, in a partial region of the image, the focus detection regionbased on designated coordinates as a center, and in a case where aregion within the image is not designated in the receiving adesignation, setting, in a partial region of the image, the focusdetection region based on a center of the image, wherein, in the secondmode, a focus state is displayed for each focus detection regionregardless of whether or not a subject is detected.
 12. A non-transitorycomputer-readable storage medium storing a program for causing acomputer to execute a control method of a focus detection apparatuswhich performs focus detection using image information obtained byperforming image capturing, the method comprising: receiving designationof a region within an image; setting one focus detection mode out of aplurality of focus detection modes, wherein the focus detection modesinclude at least a first mode for performing focus detection withpriority to a region of a subject within an image and a second mode forperforming focus detection with priority to the designated region withinthe image; setting a focus detection region for performing the focusdetection; selecting a region to focus on out of the focus detectionregion based on a focus detection result of the focus detection region;and performing focus adjustment so as to obtain image information inwhich the region to focus on is in focus, wherein in the first mode, ina case where a subject is detected, the focus detection region is setbased on the region of the subject, and in a case where a subject is notdetected, the focus detection region is set to a predetermined region,and in the second mode, the focus detection region is set based on thedesignated region, wherein in the second setting, in the second mode, ina case where a region is designated in the image in the receiving adesignation, setting, in a partial region of the image, the focusdetection region based on designated coordinates as a center, and in acase where a region within the image is not designated in the receivinga designation, setting, in a partial region of the image, the focusdetection region based on a center of the image, wherein, in the secondmode, a focus state is displayed for each focus detection regionregardless of whether or not a subject is detected.